﻿package  com.devilcat.ws{
	import com.devilcat.ws.Basicws;
	import com.worlize.websocket.*;
	
	public class Pokemonws extends Basicws{
		var mUpid:int;
		public function Pokemonws(_upid:int) {
			super("iw-protocol");
			mUpid=_upid;
		}
		override function handleWebSocketOpen(event:WebSocketEvent):void
		{
			var pack:Object = new Object();
			pack.upid=mUpid;
			pack.action="loadpokemon";
			var myJson:String = JSONString(pack);
			websocket.sendUTF(myJson);
		}
		override function handleWebSocketMessage(event:WebSocketEvent):void
		{
			if (event.message.type === WebSocketMessage.TYPE_UTF8)
			{	
				//tes =	JSONObject(event.message.utf8Data);
				trace("Got message: " + event.message.utf8Data);
			}
		}

	}
	
}
